import { InjectionKey } from "vue";
import { createStore, useStore as baseUseStore, Store } from "vuex";
import type { App } from 'vue'
import { RootStateTypes } from "./interface";
import themeConfig  from './modules/themeConfig';
import app from './modules/app'
import routesList from './modules/routesList'
import tagsViewRoutes from './modules/tagsViewRoutes'


const key: InjectionKey<Store<RootStateTypes>> = Symbol()

const store = createStore<RootStateTypes>({
  modules: {
      themeConfig,
      app,
      routesList,
      tagsViewRoutes
  }
})

export function useStore() {
    return baseUseStore(key)
}

export function setupStore(app: App<Element>) {
    app.use(store, key)
}

export default store